import java.net.URL;
import java.sql.*;
import java.util.Scanner;



public class LonginDemo {
    private static final String URL = "jdbc:mysql://localhost:3306/usersDb";
    private static final String DB_USERNAME = "root";
    private static final String DB_PASSWORD = "123456";
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection = DriverManager.getConnection(URL,DB_USERNAME,DB_PASSWORD);
        String sql = "delete from userdb where id = ?";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入ID:");
        int id = scanner.nextInt();
        System.out.println("请输入密码");
        String password = scanner.next();
        preparedStatement.setString(1,id);
       int i = preparedStatement.executeUpdate();
        if(i>0){
            System.out.println("删除成功");
        }
else {
            System.out.println("删除失败");
        }
    }
}
